package com.xgg.taiwuinfo.filter.fc;

import android.content.Context;
import android.util.Log;
import com.xgg.taiwuinfo.R;
import com.xgg.taiwuinfo.filter.FC_ContainEdit;
import com.xgg.taiwuinfo.filter.FilterComponent;
import com.xgg.taiwuinfo.gongfa.base.Gongfa;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FCNameContainEdit extends FC_ContainEdit {

    public FCNameContainEdit(JSONObject obj , Context ctx ) {
        mTypeId = FilterComponent.FT_NAME_CONTAIN_EDIT;
        if (obj != null) {
            try {
                ReadValue = obj.getString("v");
            } catch (Exception e) {
                Log.d("LoadJson", e.getLocalizedMessage());
                ReadValue = "";
            }
        } else {
            ReadValue = "";
        }
        TempValue = ReadValue;

        FieldStr = "功法名称";
        CompStr = ctx.getString(R.string.ui_contain);
    }

    @Override
    public List<Map<String, String>> getFieldString(Context ctx){
        List<Map<String, String>> mCompMap = new ArrayList<>();
        Map<String, String> map;

        map = new HashMap<>();
        map.put("f", FieldStr);
        map.put("v",   "0");
        mCompMap.add(map);

        return mCompMap;
    }

    @Override
    public List<Map<String, String>> getValueMap(Context ctx)
    {
        return null;
    }

    @Override
    public String FilterGongfa(Gongfa gongfa)
    {
        if (gongfa.mName.contains(ReadValue))
        {
            return ReadValue;
        }
        else
        {
            return null;
        }
    }
}
